import {configureStore} from "@reduxjs/toolkit";
import {TypedUseSelectorHook, useDispatch, useSelector} from "react-redux";
import {authSlice} from "@store/slices/authSlice";

//创建store对象
const store = configureStore({
    reducer:{
        [authSlice.name] : authSlice.reducer
    },
    devTools:process.env.NODE_ENV !== 'production',
})

//获取dispatch方法的类型
export type AppDispatch = typeof store.dispatch;

//用于获取带有类型的dispatch方法
export const useTypeDispatch = () => useDispatch<AppDispatch>()

//获取store中管理的状态的类型
export type AppState = ReturnType<typeof store.getState>;

//用于获取带有类型的useSeletor方法
export const useTypeSelector:TypedUseSelectorHook<AppState> = useSelector;

//默认导出store
export default store
